home *** CD-ROM | disk | FTP | other *** search
- package horst;
-
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Rectangle;
- import java.awt.Shape;
- import java.awt.Toolkit;
- import java.awt.image.ImageObserver;
- import java.net.URL;
-
- public class BodyView extends BlockView implements ImageObserver {
- Image m_bkgImage;
- Color m_bkgColor;
-
- public BodyView(View parent, Element e, HTMLPane container) {
- super(parent, e, container);
- }
-
- public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) {
- if (this.m_bkgImage == null) {
- return false;
- } else if ((flags & 192) != 0) {
- this.m_bkgImage = null;
- return false;
- } else {
- if ((flags & 48) != 0) {
- super.m_container.repaint((long)super.m_bounds.x);
- }
-
- return true;
- }
- }
-
- protected void init() {
- URL u = Utilities.setURLProperty(super.m_elem.getDocument().getBaseURL(), "background", super.m_elem.getAttributes());
- if (u != null) {
- this.m_bkgImage = Toolkit.getDefaultToolkit().getImage(u);
- if (this.m_bkgImage != null) {
- Toolkit.getDefaultToolkit().prepareImage(this.m_bkgImage, -1, -1, this);
- }
- }
-
- this.m_bkgColor = Utilities.setColorProperty((Color)null, "bgcolor", super.m_elem.getAttributes());
- ((View)this).setInsets(super.m_container.m_props.m_marginHeight, super.m_container.m_props.m_marginWidth, super.m_container.m_props.m_marginHeight, super.m_container.m_props.m_marginWidth);
- }
-
- protected boolean isFloaterClearer() {
- return true;
- }
-
- protected boolean isWrappable() {
- return true;
- }
-
- protected void makeChildren(ViewFactory factory) {
- super.makeChildren(factory);
- if (super.m_children.length > 0 && super.m_children[0] instanceof FrameSetView) {
- ((View)this).setInsets(0, 0, 0, 0);
- }
-
- }
-
- public void paint(Graphics g, Shape alloc) {
- if (super.m_bounds.intersects(alloc.getBounds())) {
- Rectangle allocation = alloc.getBounds();
- int screenWidth = Math.max(allocation.width, super.m_bounds.width + super.m_insets.left + super.m_insets.right);
- int screenHeight = Math.max(allocation.height, super.m_bounds.height + super.m_insets.top + super.m_insets.bottom);
- if (this.m_bkgColor != null) {
- g.setColor(this.m_bkgColor);
- g.fillRect(super.m_bounds.x, super.m_bounds.y, screenWidth, screenHeight);
- }
-
- if (this.m_bkgImage != null && super.m_container.m_props.m_bDisplayBackgroundImage) {
- int w = this.m_bkgImage.getWidth((ImageObserver)null);
- int h = this.m_bkgImage.getHeight((ImageObserver)null);
- int nCols = 1;
- int nRows = 1;
- if (screenWidth > w) {
- nCols = screenWidth / w;
- double rem = (double)screenWidth / (double)w - (double)nCols;
- if (rem > (double)0.0F) {
- ++nCols;
- }
- }
-
- if (screenHeight > h) {
- nRows = screenHeight / h;
- double rem = (double)screenHeight / (double)h - (double)nRows;
- if (rem > (double)0.0F) {
- ++nRows;
- }
- }
-
- for(int row = 0; row < nRows; ++row) {
- for(int col = 0; col < nCols; ++col) {
- g.drawImage(this.m_bkgImage, col * w, row * h, w, h, (ImageObserver)null);
- }
- }
- }
-
- super.paint(g, alloc);
- }
-
- }
- }
-